home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / play movie / start code / pmutilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-06  |  3.5 KB  |  180 lines

  1. /*
  2.     File:        PMUtilities.c
  3.     
  4.     Contains:    QuickTime sample code
  5.  
  6.     Copyright:    © 2000 by Apple Computer, Inc. All rights reserved
  7.  
  8.  
  9. */
  10.  
  11. #include <MacTypes.h>
  12. #include <Gestalt.h>
  13. #include <Movies.h>
  14. #include "ComFramework.h"
  15. #include "MacFramework.h"
  16. #include "PMUtilities.h"
  17.  
  18. // Global UPP for PrePreroll
  19. // A routine descriptor for our pre-preroll completion routine
  20. MoviePrePrerollCompleteUPP gMoviePPRollCompleteProc = NULL;
  21.  
  22. //////////
  23. //
  24. // QTIsQuickTimeInstalled
  25. // Is QuickTime installed?
  26. //
  27. //////////
  28.  
  29. Boolean IsQuickTimeInstalled (void) 
  30. {
  31.  
  32. // Insert IsQuickTimeInstalled.clp here...
  33.  
  34.     return(myErr == noErr);
  35. }
  36.  
  37.  
  38. //////////
  39. //
  40. // QTQuickTimeCFMInstalled
  41. // Are the QuickTime CFM libraries installed?
  42. //
  43. //////////
  44.  
  45. #if TARGET_CPU_PPC
  46. Boolean IsQuickTimeCFMInstalled (void) 
  47. {
  48.     Boolean     myQTCFMAvail = false;
  49.     long        myAttrs;
  50.     OSErr         myErr = noErr;
  51.  
  52.     // Test whether the PowerPC QuickTime glue library is present
  53.  
  54. // Insert IsQuickTimeCFMInstalled.clp here...
  55.  
  56.  
  57.     // Test whether a function is available (the library is not moved from the Extension folder);
  58.     // This is the trick to be used when testing if a function is available via CFM
  59.     if (!CompressImage)
  60.         myQTCFMAvail = false;     
  61.  
  62.     return(myQTCFMAvail);
  63. }
  64. #endif
  65.  
  66. void DoInitQuickTime( void )
  67. {
  68.     OSErr myErr;
  69.     
  70. // Insert EnterMovies.clp here...
  71.  
  72.  
  73.     if (myErr != noErr) {
  74.         QTFrame_ShowWarning("\pCould not initialize QuickTime. Exiting.", myErr);
  75.         ExitToShell();
  76.     }
  77.     
  78.     gMoviePPRollCompleteProc = NewMoviePrePrerollCompleteProc(MoviePrePrerollCompleteProc);
  79.     
  80.     return;
  81. }
  82.  
  83. //////////
  84. //
  85. // GetWindowPositionFromFile
  86. // Return, through thePoint, the stored position of the specified movie.
  87. //
  88. // Return an error if the movie has no stored position. In any case, return a meaningful position.
  89. //
  90. //////////
  91.  
  92. OSErr GetWindowPositionFromFile (Movie theMovie, Point *thePoint)
  93. {
  94.     UserData        myUserData = NULL;
  95.     Point            myPoint = {kDefaultWindowX, kDefaultWindowY};
  96.     OSErr            myErr = paramErr;
  97.     
  98.     if (theMovie == NULL)
  99.         goto bail;
  100.         
  101.     // get the movie's user data list
  102.     
  103. // Step 1.
  104. // Insert GetMovieUserData.clp here...
  105.  
  106.     
  107.     if (myUserData != NULL) {
  108. // Step 2.
  109. // Insert GetUserDataItem.clp here...
  110.  
  111.  
  112.         if (myErr == noErr) {
  113.             //  Endian Flipping Big to Native - This will do the right thing on Windows
  114.             myPoint.v = EndianS16_BtoN(myPoint.v);
  115.             myPoint.h = EndianS16_BtoN(myPoint.h);
  116.         }
  117.     }
  118.  
  119. bail:
  120.     *thePoint = myPoint;
  121.  
  122.     return(myErr);
  123. }
  124.  
  125. //////////
  126. //
  127. // MoviePrePrerollCompleteProc
  128. // A completion procedure for preprerolling movies.
  129. //
  130. // The theRefCon parameter is assumed to be a window object.
  131. //
  132. //////////
  133.  
  134. PASCAL_RTN void MoviePrePrerollCompleteProc (Movie theMovie, OSErr thePrerollErr, void *theRefCon)
  135. {
  136. #pragma unused(thePrerollErr)
  137.  
  138.     WindowObject        myWindowObject = (WindowObject)theRefCon;
  139.  
  140.     if ((theMovie == NULL) || (myWindowObject == NULL))
  141.         return;
  142.     
  143. // Insert PrerollComplete.clp here...
  144.  
  145. }
  146.  
  147. //////////
  148. //
  149. // Preroll
  150. //
  151. // Preroll the movie, so that it's ready to play when we call StartMovie
  152. //
  153. //////////
  154.  
  155. void PrerollAndPlay( Movie theMovie )
  156. {
  157.  
  158. // Insert Preroll.clp here...
  159.  
  160. }
  161.  
  162. //////////
  163. //
  164. // StartPlayingMovie
  165. // If the movie is at the end it will take it back to the beginning then start playing it.
  166. //
  167. //////////
  168.  
  169. void StartPlayingMovie(Movie theMovie, Fixed thePlayRate)
  170. {
  171.  
  172.     long theLoopingInfo;
  173.     QTUtils_GetMovieFileLoopingInfo(theMovie, &theLoopingInfo);
  174.     if(theLoopingInfo == kNoLooping)
  175.         if(GetMovieTime(theMovie, NULL) == GetMovieDuration(theMovie) && !QTUtils_IsStreamedMovie(theMovie))
  176.             GoToBeginningOfMovie(theMovie);
  177.             
  178. // Insert StartMovie.clp here...
  179.  
  180. }